package com.qdu.mapper;

import com.qdu.bean.RentCarBean;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class MaxUsageByWindspeedMapper  extends Mapper<LongWritable, Text, DoubleWritable, RentCarBean> {
    private DoubleWritable k = new DoubleWritable();
    private RentCarBean v = new RentCarBean();
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String[] items = value.toString().split(",");

        double windSpeed = Double.parseDouble(items[8]);
        int casual = Integer.parseInt(items[9]);      //未注册的人数
        int registered = Integer.parseInt(items[10]); //注册了的人数
        int count = Integer.parseInt(items[11]);      //注册+未注册

        k.set(windSpeed);
        v.set1(casual,registered,count);

        context.write(k,v);
    }
}
